package com.sondon.dev_soceket.model;

import com.sondon.dev_soceket.tcp.util.CodeUtil;

/**
 * @Project : 硬件通讯
 * @Package : com.sondon.model
 * @Class : Entity.java
 * @Company 广州讯动网络科技有限公司
 * @Author : 蔡文锋
 * @DateTime：2015年4月2日 上午7:14:58
 * @Blog：http://blog.csdn.net/caiwenfeng_for_23
 * @Description : {
 * 
4A 79 //包开始标志HEAD
00 00 //包流号 PACKNO

00 00 00 00 // 源地址SADR   保留
00 00 00 00 // 目标地址DADR    保留
00 00 00 00 // 端口 PORT     保留
00 00 //包信息 FLAG    保留
 
05 0A // 指令字CMD
4E 00 // 数据长度 LEN

// 数据 DATA
00 00 04 00 07 60 00 03 61 30 30 30 30 30 30 30 30 30 30 30 30 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0C 60 00 00 61 C9 E8 B1 B8 
C3 FB B3 C6 3A 53 45 44 36 34 35 30 4D 20 20 B0 E6 B1 BE 3A 56 31 2E 30 30 
2E 30 30 

70 96 // 数据的CRC16值
 *  
 *  }
 */
public class Entity {
	String HEAD;
	String PACKNO;
	String SADR ; 
	String  DADR;
	String  PORT;
	String  FLAG;
	String  CMD;
	String  LEN;
	String  DATA;
	String  CRC16;
	
	/**
	 * @return the hEAD
	 */
	public String getHEAD() {
		return HEAD;
	}
	/**
	 * @param hEAD the hEAD to set
	 */
	public void setHEAD(String hEAD) {
		HEAD = hEAD;
	}
	/**
	 * @return the pACKNO
	 */
	public String getPACKNO() {
		return PACKNO;
	}
	/**
	 * @param pACKNO the pACKNO to set
	 */
	public void setPACKNO(String pACKNO) {
		PACKNO = pACKNO;
	}
	/**
	 * @return the sADR
	 */
	public String getSADR() {
		return SADR;
	}
	/**
	 * @param sADR the sADR to set
	 */
	public void setSADR(String sADR) {
		SADR = sADR;
	}
	/**
	 * @return the dADR
	 */
	public String getDADR() {
		return DADR;
	}
	/**
	 * @param dADR the dADR to set
	 */
	public void setDADR(String dADR) {
		DADR = dADR;
	}
	/**
	 * @return the pORT
	 */
	public String getPORT() {
		return PORT;
	}
	/**
	 * @param pORT the pORT to set
	 */
	public void setPORT(String pORT) {
		PORT = pORT;
	}
	/**
	 * @return the fLAG
	 */
	public String getFLAG() {
		return FLAG;
	}
	/**
	 * @param fLAG the fLAG to set
	 */
	public void setFLAG(String fLAG) {
		FLAG = fLAG;
	}
	/**
	 * @return the cMD
	 */
	public String getCMD() {
		return CMD;
	}
	/**
	 * @param cMD the cMD to set
	 */
	public void setCMD(String cMD) {
		CMD = cMD;
	}
	/**
	 * @return the lEN
	 */
	public String getLEN() {
		return LEN;
	}
	/**
	 * @param lEN the lEN to set
	 */
	public void setLEN(String lEN) {
		LEN = lEN;
	}
	/**
	 * @return the dATA
	 */
	public String getDATA() {
		return DATA;
	}
	/**
	 * @param dATA the dATA to set
	 */
	public void setDATA(String dATA) {
		DATA = dATA;
	}
	/**
	 * @return the cRC16
	 */
	public String getCRC16() {
		return CRC16;
	}
	/**
	 * @param cRC16 the cRC16 to set
	 */
	public void setCRC16(String cRC16) {
		CRC16 = cRC16;
	}

	/**
	 * 构造函数
	 */
	public Entity() {
		this. HEAD="4A79";
		this.PACKNO="0000";
		this.SADR="00000000" ; 
		this.DADR="00000000" ;
		this.PORT="00000000" ; 
		this.FLAG="0000";
	}
	
	/**
	 * 
	 * @Author 蔡文锋
	 * @Data_Time  2015年4月2日 上午10:27:59
	 * @Description {
	 *  对数据进行编码
	 *   }
	 * @return
	 */
	public byte[] EnCode(){
		String data=this.HEAD+this.PACKNO+this.SADR+this.DADR+this.PORT+this.FLAG+this.CMD+this.LEN+this.DATA+this.CRC16;
		return CodeUtil.hexStringToBytes(data);
	}
	
	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		// TODO Auto-generated method stub
		return "head :"+this.HEAD+"\n packno:"+this.PACKNO+"\n sadr: "+this.SADR+"\n dadr: "+this.DADR+"\n  port: "+this.PORT+"\n flag: "+this.FLAG+"\n cmd: "+this.CMD+"\n len: "+this.LEN+"\n  data: "+this.DATA+"\n crc16: "+this.CRC16;
	}
}
